<template>
	<div class="demo2">
		<h2>我是Demo2组件</h2>
		<h3>自己家的msg2：{{msg2}}</h3>
		<h3>收到的msg1：{{msg1}}</h3>
	</div>
</template>

<script>
	export default {
		name:'Demo2',
		data() {
			return{
				msg2:'吃饭了吗',
				msg1:''
			}
		},
		methods:{
			demo(value){
				console.log('demo被调用了，说明x这傀儡身上的xiaozhu事件被触发了',value)
				this.msg1 = value
			}
		},
		mounted(){
			this.$bus.$on('xiaozhu',this.demo)
		},
		beforeDestroy() {
			this.$bus.$off('xiaozhu')
		},
	}
</script>

<style>
	.demo2{
		background-color: skyblue;
		padding: 10px;
	}
</style>